def move 990
def bodya 989
def nrga 987
def nrgb 986
def bodyb 985

'ID gene - Endy
cond
*.robage 0 =
start
300 .bodya store
500 .nrga store
.thisgene .memloc store
100 .mkshell store
.tie inc
stop

'memloc check
cond
*.memloc .thisgene !=
start
.thisgene .memloc store
stop

'eye4
cond
*.paralyzed 0 =
*.poisoned 0 =
*.eye5 0 =
*.eye4 0 >
*.eye4 *.eye3 >=
*.eye4 *.eye2 >=
*.eye4 *.eye1 >=
*.eye4 *.eye6 >=
*.eye4 *.eye7 >=
*.eye4 *.eye8 >=
*.eye4 *.eye9 >=
start
*.aim 35 add .setaim store
stop

'eye6
cond
*.paralyzed 0 =
*.poisoned 0 =
*.eye5 0 =
*.eye6 0 >
*.eye6 *.eye4 >
*.eye6 *.eye7 >=
*.eye6 *.eye8 >=
*.eye6 *.eye9 >=
*.eye6 *.eye1 >=
*.eye6 *.eye2 >=
*.eye6 *.eye3 >=
start
*.aim -35 add .setaim store
stop

'eye3
cond
*.paralyzed 0 =
*.poisoned 0 =
*.eye5 0 =
*.eye3 0 >
*.eye3 *.eye4 >
*.eye3 *.eye6 >
*.eye3 *.eye2 >=
*.eye3 *.eye1 >=
*.eye3 *.eye7 >=
*.eye3 *.eye8 >=
*.eye3 *.eye9 >=
start
*.aim 70 add .setaim store
stop

'eye7
cond
*.paralyzed 0 =
*.poisoned 0 =
*.eye7 0 >
*.eye5 0 =
*.eye7 *.eye4 >
*.eye7 *.eye6 >
*.eye7 *.eye3 >
*.eye7 *.eye2 >=
*.eye7 *.eye1 >=
*.eye7 *.eye8 >=
*.eye7 *.eye9 >=
start
*.aim -70 add .setaim store
stop

'eye2
cond
*.paralyzed 0 =
*.poisoned 0 =
*.eye2 0 >
*.eye5 0 =
*.eye2 *.eye4 >
*.eye2 *.eye3 >
*.eye2 *.eye7 >
*.eye2 *.eye6 >
*.eye2 *.eye1 >=
*.eye2 *.eye9 >=
*.eye2 *.eye8 >=
start
*.aim 105 add .setaim store
stop

'eye8
cond
*.paralyzed 0 =
*.poisoned 0 =
*.eye8 0 >
*.eye5 0 =
*.eye8 *.eye2 >
*.eye8 *.eye3 >
*.eye8 *.eye4 >
*.eye8 *.eye7 >
*.eye8 *.eye6 >
*.eye8 *.eye1 >=
*.eye8 *.eye9 >=
start
*.aim -105 add .setaim store
stop

'eye1
cond
*.paralyzed 0 =
*.poisoned 0 =
*.eye5 0 =
*.eye1 0 >
*.eye1 *.eye2 >
*.eye1 *.eye3 >
*.eye1 *.eye4 >
*.eye1 *.eye6 >
*.eye1 *.eye7 >
*.eye1 *.eye8 >
*.eye1 *.eye9 >=
start
*.aim 140 add .setaim store
stop

'eye9
cond
*.paralyzed 0 =
*.poisoned 0 =
*.eye5 0 =
*.eye9 0 >
*.eye9 *.eye1 >
*.eye9 *.eye2 >
*.eye9 *.eye8 >
*.eye9 *.eye7 >
*.eye9 *.eye6 >
*.eye9 *.eye4 >
*.eye9 *.eye3 >
start
*.aim -140 add .setaim store
stop

'rotate if all eyes empty and not being shot
cond
*.paralyzed 0 =
*.poisoned 0 =
*.eye5 0 =
*.eye4 0 =
*.eye3 0 =
*.eye2 0 =
*.eye1 0 =
*.eye6 0 =
*.eye7 0 =
*.eye8 0 =
*.eye9 0 =
*.shflav 0 =
*.shflav -2 = or
start
*.aim 280 add .setaim store
stop

'follow friend if not being shot
cond
*.paralyzed 0 =
*.poisoned 0 =
*.in1 0 !=
*.in2 0 != or
*.memval *.genes =
*.refage 0 >
*.eye5 0 >
*.shflav 0 =
*.shflav -2 = or
start
*.in1 *.in2 angle .setaim store
*.in1 *.in2 dist 500 div *.maxvel mult *.refvel add 0 floor *.maxvel ceil .up store
*.veldx .sx store
stop

'avoid friend when not getting shot
cond
*.paralyzed 0 =
*.poisoned 0 =
*.in1 0 =
*.in2 0 = and
*.memval *.genes =
*.refage 0 >
*.eye5 0 >
*.shflav 0 =
*.shflav -2 = or
start
*.refxpos *.refypos angle 280 add .setaim store
stop

'if see friend but getting shot
cond
*.paralyzed 0 =
*.poisoned 0 =
*.in1 0 =
*.in2 0 = and
*.memval *.genes =
*.refage 0 >
*.eye5 0 >
*.shflav 0 !=
*.shflav -2 != and
start
*.shang .setaim store
0 .shflav store
-1 .shoot store
*.shang *.aim add .aimshoot store
stop

'all eyes empty but being shot
cond
*.paralyzed 0 =
*.poisoned 0 =
*.eye5 0 =
*.eye4 0 =
*.eye3 0 =
*.eye2 0 =
*.eye1 0 =
*.eye6 0 =
*.eye7 0 =
*.eye8 0 =
*.eye9 0 =
*.shflav 0 !=
*.shflav -2 != and
start
*.shang .setaim store
0 .shflav store
-1 .shoot store
*.shang *.aim add .aimshoot store
stop

'follow friend if not being shot
cond
*.paralyzed 0 =
*.poisoned 0 =
*.in1 0 !=
*.in2 0 != or
*.memval *.genes =
*.refage 0 >
*.eye5 0 >
*.shflav 0 =
*.shflav -2 = or
start
*.in1 *.in2 angle .setaim store
*.in1 *.in2 dist 500 div *.maxvel mult *.refvel add 0 floor *.maxvel ceil .up store
*.veldx .sx store
stop

'don't follow friend if getting shot
cond
*.paralyzed 0 =
*.poisoned 0 =
*.in1 0 !=
*.in2 0 != or
*.memval *.genes =
*.refage 0 >
*.eye5 0 >
*.shflav 0 !=
*.shflav -2 != and
start
*.shang .setaim store
0 .shflav store
-1 .shoot store
*.shang *.aim add .aimshoot store
stop

'target and shoot
cond
*.paralyzed 0 =
*.poisoned 0 =
*.robage 1 >
*.eye5 9 >
*.memval *.genes !=
'*.numties 0 =
start
*.refxpos *.refypos angle *.aim sub .aimshoot store
-6 .shoot store
*.nrg 32 div .shootval store
stop

'move and communicate
cond
*.paralyzed 0 =
*.poisoned 0 =
*.robage 1 >
*.eye5 0 >
*.memval *.genes !=
*.numties 0 =
start
*.refxpos *.refypos angle .setaim store
*.refxpos *.refypos dist 500 div *.maxvel mult *.refvel add 0 floor *.maxvel ceil .up store
*.veldx .sx store
*.refxpos .out1 store
*.refypos .out2 store
stop

'refresh communication or hide veg location
cond
*.paralyzed 0 =
*.poisoned 0 =
*.refeye 0 =
*.eye5 0 = or
*.memval *.genes =
*.eye5 0 > and
*.in1 0 = and
*.in2 0 = and or
*.out1 0 !=
*.out2 0 != or
start
0 .out1 store
0 .out2 store
stop

'turn back after repro
cond
*.paralyzed 0 =
*.poisoned 0 =
*.move 0 !=
start
*.aim 628 add .setaim store
.move dec
1 .deltie store
0 .shoot store
stop

'baby avoids mum
cond
*.paralyzed 0 =
*.poisoned 0 =
*.robage 1 =
*.numties 0 >
*.memval *.genes = or
start
*.aim 280 add .setaim store
0 .shoot store
stop

'repro
cond
*.paralyzed 0 =
*.poisoned 0 =
*.eye5 0 =
*.move 0 =
*.body *.bodya >
*.nrg *.nrga >
start
25 .repro store
*.aim 628 add .setaim store
1 .move store
*.bodya 10 div *.bodya add 30000 ceil .bodya store
*.nrga 10 div *.nrga add 30000 ceil .nrga store
stop

'delete tie
cond
*.numties 0 >
start
*.tiepres .deltie store
stop

'make body
cond
*.paralyzed 0 =
*.poisoned 0 =
*.nrg *.nrga >
*.body 3190 <
start
100 .strbody store
stop

'use body
cond
*.paralyzed 0 =
*.poisoned 0 =
*.nrg *.nrgb <
*.body 11 >
start
100 .fdbody store
stop

'make more shell
cond
*.paralyzed 0 =
*.poisoned 0 =
*.shell 100 <
*.nrg 500 > and
*.shflav -6 = or
*.shflav -3 = or
start
50 .mkshell store
0 .shflav store
stop

'poop
cond
*.paralyzed 0 =
*.poisoned 0 =
*.waste 50 >
*.memval *.genes !=
start
-4 .shoot store
*.waste .shootval store
stop

'Death by Baby!
cond
*.poisoned 0 !=
*.paralyzed 0 != or
start
100 .repro store
*.aim 280 add .setaim store
*.aim 280 add .aimshoot store
stop

'ID gene - Endy
cond
start
*.nrga 2 div .nrgb store
' little constant viral defense gene doubles as ID gene
*.genes .delgene
 .fixpos *.fixed mult dec 'anti fixpos by Elite
*.thisgene *.genes sub dup div
mult *.robage sgn mult store
.genes inc
stop
end